﻿using System.Collections.Generic;
using Entitas;
class PlayerMovementRequestSystem : ReactiveSystem<PlayerEntity>
{
    RequestContext requestContext;
    public PlayerMovementRequestSystem(Contexts contexts) : base(contexts.player)
    {
        requestContext = contexts.request;
    }
   
    protected override void Execute(List<PlayerEntity> entities)
    {
        foreach(var e in entities)
        {
            requestContext.CreateEntity().AddMovementRequest(e.name.value, e.direction.value);
        }
    }

    protected override bool Filter(PlayerEntity entity)
    {
        return entity.hasDirection && entity.hasName;
    }

    protected override ICollector<PlayerEntity> GetTrigger(IContext<PlayerEntity> context)
    {
        return context.CreateCollector(PlayerMatcher.Direction.AddedOrRemoved());
    }
}
